﻿namespace MultiService;

/// <summary>
/// 模拟一个子Web服务
/// </summary>
public class SubService : IHostedService
{
    public Task StartAsync(CancellationToken cancellationToken)
    {
        var app = WebApplication.Create();
        app.MapGet("/", () =>
        {
            return "Sub Web Server";
        });

        app.RunAsync("http://*:5002");
        return Task.CompletedTask;
    }

    public Task StopAsync(CancellationToken cancellationToken)
    {
        // TODO: 取消服务
        return Task.CompletedTask;
    }
}
